<template>
  <div>

    <!-- 传入字符串内容不需要加冒号 -->
    <MyHeaderVue background="#ffb413" title="购物车列表" ></MyHeaderVue>
    <div id="main">
      <MyGoodsVue v-for="obj in list" :key="obj.id" :gObj="obj"></MyGoodsVue>
    </div>
    <MyFooterVue @isAll="chooseAll" :obj="list"></MyFooterVue>
    
  </div>
</template>

<script>

  import MyHeaderVue from './components/MyHeader.vue';
  import MyGoodsVue from './components/MyGoods.vue';
  import MyFooterVue from './components/MyFooter.vue';
export default {
   data(){
    return{
      list:[]
    }
   },
  components:{
    MyHeaderVue,
    MyGoodsVue,
    MyFooterVue
  },
  created(){
    this.$axios({
      url:'/api/cart'
    }).then((res)=>{
      this.list=res.data.list
      console.log(res);
    })
    
  },
  methods:{
    chooseAll(val){
      this.list.forEach(obj=> obj.goods_state=val)
    }

  }
}
</script>

<style scoped>

  #main{
    margin-top: 50px;
    margin-bottom: 45px;
  }

</style>